<head>
    <meta charset="utf-8" />
    <title>socket io</title>
    <script type="text/javascript" src="js/lib/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="js/lib/socket.io.js"></script>
    <script type="text/javascript">
    var socket = io.connect(); //与服务器进行连接  
    console.log(socket)
    function sendMSG() {
        console.log('hehe')
        socket.emit('foo', 'hello'); //发送一个名为foo的事件，并且传递一个字符串数据‘hello’  
    }
    var a=socket.on("req",function(data){
        console.log(data);
        return data;
    });
    </script>
</head>

<body>
    <button onclick="sendMSG()">sendMSG</button>
</body>

</html>
